class EditorGroup < ActiveRecord::Base
  has_and_belongs_to_many(:page)
  has_and_belongs_to_many(:document_category)
  has_and_belongs_to_many(:folder)
  has_and_belongs_to_many(:user)

  validates_presence_of(:name)

  def has_user_id?(uid)
    return false unless uid
    user.each{|usr| return true if usr.id == uid}
    return false
  end

  def has_document_category_id?(dc_id)
    return false unless dc_id
    document_category.each{|dc| return true if dc.id == dc_id}
    return false
  end

  def has_page_id?(pg_id)
    return false unless pg_id
    page.each{|pg| return true if pg.id == pg_id}
    return false
  end

  def has_folder_id?(fid)
    return false unless fid
    folder.each{|fldr| return true if fldr.id == fid}
    return false
  end

end
